<template>
	<view class="page">
		<view class="container">
			<view class="box">
				
				<view class="uni-padding-wrap ">
					<view class="uni-common-mt">
						<!-- <image :src="resultList.content" class="png" mode="widthFix" style="width: 100%;"></image> -->
						<view class="html"><rich-text  :nodes="resultList.content.html"></rich-text></view>
						
					</view>
				</view>
				<view class="cu-item bottom" v-if="0">
					<view class="content text-blue ask" @click="doAsk()"> 
						<!-- <image :src="resultList.cover_image" class="myCode" show-menu-by-longpress="true"></image> -->
						<view >咨询电话：{{resultList.description+'   '+resultList.keywords}}</view>
					</view>
				</view>
			</view>
			<view class="flex flex-wrap text-black text-lg pay-row" >
				<button class="bg-orange action-btn" open-type="share" @click="wx_share">分享</button>
			<button class="bg-green action-btn"  @click="goAsk" v-if="resultList.isAsk=='F'">咨询</button>
			</view>
		</view>
		
	<!-- 绑定 -->
	<goReg 
		ref="goReg" 
		:contentHeight="580" @eventBind="Bind($event)"
	></goReg>
	</view>
	<!-- <web-view  src=" https://apitest.hrzhizhang.com/admin/article/index"></web-view> -->
	
</template>

<script>
	import goReg from "@/components/goReg";
	
	export default {
		components: {
			goReg
		},
		data() {
			return {
				title:'',
				param:'',
				uid:'',
				resultList:[],
				worksList: [],
				typeState: [],
				scrollHeight:'460px',
			};
		},
		// onReady: function(res) {
		// 	this.videoContext = uni.createVideoContext('myVideo');
		// },
		onShareAppMessage() {
			let uId = uni.getStorageSync('userId');
			let param = this.title
			// const promise = new Promise(resolve => {
			// 	resolve({
			// 		title: title+'-职位详情',
			// 		})
			// 	})
			return {
				title: this.title,
				path: '/pages/tabbar/tabbar-4/company?cid='+uId+'&t='+this.param,
				// promise 
			}
		},
		onLoad(option) {
			let cid = option.cid;
			uni.setStorageSync('cid',cid)
			console.log(option)
			console.log('cid'+cid)
			
			let title = option.t;
			this.param = title;
			this.title = title;
			uni.setNavigationBarTitle({
				title: title
			});
			this.uId = uni.getStorageSync('userId');
			let obj = uni.getSystemInfoSync();
			let clientHeight = obj.screenHeight;
			this.scrollHeight = clientHeight-50+'px';
			// console.log(aid)
			if(this.uId>"0"&&this.uId!=undefined){
				// this.userInfo = uni.getStorageSync('userInfo');
				this.loadData();
			}
			else{
				this.$refs.goReg.showModal('regModal');	
			}
			
			this.getTableState()
			
			wx.showShareMenu();
		},
		methods: {
			Bind(){
				this.loadData();
			},
			async getTableState() {
				let param = 'articles';
				let t = this;
				let data = await this.$http.get(
					'wx/common_get_table_status/' + param, //可以直接放链接(将不启用全局定义域名)
				);
				// t.provinceData=[''];
				// t.citysData = ['请选择']var arr = []
				t.typeState = data
				let title = this.typeState.title[t.title]
				if(title==undefined){
					title = this.typeState.service[t.title]	
				}
				t.title = title;
				uni.setNavigationBarTitle({
				    title: t.title
				});
				
				console.log(data);
			},
			async goAsk(){
				this.uId = uni.getStorageSync('userId');
				
				console.log(this.uId)
				if(this.uId>"0"&&this.uId!=undefined){
					// this.userInfo = uni.getStorageSync('userInfo');
					let t = this
					let param = {
						seeker_id:t.uId,
						project_id:t.resultList.id
						}
					
					// let data = await this.$http.post('fiveRisks',{city:'重庆市',wages_before:'10000',wages_real:'6000'});
					let data = await this.$http.post(
						'wx/track', //可以直接放链接(将不启用全局定义域名)
						param, 
					);
					t.resultList.isAsk='T'
					setTimeout(()=>{
						uni.showToast({
							title: '操作成功',
							icon: 'none'
						})
					}, 500)
					return;
				}
				this.$refs.goReg.showModal('regModal');	
				
			},
			doAsk(){
				let t = this;
				uni.makePhoneCall({
				    phoneNumber: t.resultList.description
				});
			},
			/**
			 * 请求静态数据只是为了代码不那么乱
			 * 分次请求未作整合
			 */
			wx_share(){
				wx.showShareMenu();
				
			},
			async loadData() {
				let t = this
				t.uId = uni.getStorageSync('userId');
				let param = {title:this.title};
				if(t.uId!=undefined&&t.uId>''){
					param.uid = t.uId
				}
				// let data = await this.$http.post('fiveRisks',{city:'重庆市',wages_before:'10000',wages_real:'6000'});
				let data = await this.$http.post(
					'wx/article_info', //可以直接放链接(将不启用全局定义域名)
					param, 
				);
				this.resultList = data;
				console.log(data);
				
			},
			
			//详情页
			navToDetailPage(item) {
				if(!this.hasLogin){
					uni.navigateTo({
						url: '/pages/public/login'
					})
					return
				}
				// uni.showToast({
				// 	title: `功能开发中...`,
				// 	icon: 'none'
				// })
				// return
				//测试数据没有写id，用title代替
				let id = item.title;
				uni.navigateTo({
					url: `/pages/works/detail?id=${id}`
				})
			},
		},
		
	}
</script>

<style lang="scss">
	
	.page{
		height: 100Vh;
		width: 100vw;
		background: #F6F6F6;
	}
	
	.box{
		margin-bottom: 0px;
		background: #FFFFFF;
	}
	.myCode{
		// position: absolute;
		width: 100%;
		height: 100px;
	}
	.bottom{
		height: 150px;
	}
	.ask{
		display: flex;
		justify-content: center;
		align-items: center;
		height: 50px !important;
		background: #ffffffd9 !important;
	}
	.action-btn{
		height: 35px;
		padding: 5px 0;
		margin-top: 5px;
		width: 150px;
		// background:#FE7D4C;
		border-radius: 4rem;
		font-size:16px;
		line-height: 28px;
		color:white;
	}
	.pay-row{
		position: fixed;
		bottom: 15px;
		width: 100%;
		z-index:998;
		.price{
			margin-left: 20px;
			color:gray;
			line-height: 50px;
			width: 40%;
		}
	}
	

</style>
